package mvc;

import java.awt.Component;
import java.awt.Container;

import mvc.model.CGridModel;
import mvc.model.IModel;
import mvc.view.IModelView;
import mvc.view.IView;
import mvc.view.forms.CDeutschGridForm;
import utils.Tracer;

public class CFormController {
	private Container appContainer;

	public Container getAppContainer() {
  	return appContainer;
  }

	public void setAppContainer(Container pAppContainer) {
  	this.appContainer = pAppContainer;
  }

	public void createChild(Class<IView> pFormClass){
		IModelView newView = null;
		if (pFormClass == null)
		{
			newView = new CDeutschGridForm();
		}
		else {
			try {
				newView = (IModelView) pFormClass.newInstance();         
			} catch (Exception e) {
			  Tracer.trace(e);
			}
		}		
		
		IModel newModel = new CGridModel();
		
		newView.setModel(newModel);
		
		appContainer.add((Component) newView);  
	}
}
